<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html  xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:p="http://primefaces.org/ui">
    <h:head>
    </h:head>
    <h:body>
        <ui:composition>
            <p:outputPanel>
                <p:dataTable id="tblUser_Data" value="#{func_admin_user.listUG}" var="user" rowKey="#{user.USER_ID}" rowIndexVar="indexv" style="border: 5px" selection="#{func_admin_user.user}" selectionMode="single">
                    <p:ajax event="rowSelect" listener="#{func_admin_user.onRowSelect()}" process="@this :form_main_admin:tblUser_Data" partialSubmit="true" update=":form_main_admin:dialogUser :form_main_admin:tblUser_Data"/>
                    <f:facet name="header">  
                        <h:outputText value="Users Management" style="font-size:15px"/>
                    </f:facet>
                    <p:column headerText="Index" style="width: 5%; font-size: 15px">
                        #{indexv + 1}
                    </p:column>
                    <p:column headerText="User ID" style="text-align: center; font-size: 15px">
                        #{user.USER_ID}
                    </p:column>
                    <p:column headerText="User Name" style="text-align: center; font-size: 15px">
                        #{user.USER_NAME}
                    </p:column>
                    <p:column headerText="User Password" style="text-align: center; font-size: 15px">
                        #{user.USER_PASSWORD}
                    </p:column>
                    <p:column headerText="Full Name" style="text-align: center; font-size: 15px">
                        #{user.FULL_NAME}
                    </p:column>
                    <p:column headerText="Status" style="text-align: center; font-size: 15px">
                        <h:outputText value="#{func_admin_user.activeState.get(indexv)}"/>
                    </p:column>
                    <p:column headerText="Email" style="text-align: center; font-size: 15px">
                        #{user.USER_EMAIL}
                    </p:column>
                    <p:column headerText="Group Name" style="text-align: center; font-size: 15px">
                        #{user.GROUP_NAME}
                    </p:column>
                    <f:facet name="footer">  
                        <p:commandButton id="add-id" value="Add" style="width: 60px; height: 30px; text-align: center; font-size: 12px" oncomplete="UserDialog.show()" actionListener="#{func_admin_user.handAdd()}" update=":form_main_admin:dialogUser :form_main_admin:tblUser_Data" process="@this :form_main_admin:tblUser_Data" disabled="#{not func_admin_user.ctrlAdd}"></p:commandButton>
                        <p:commandButton id="edit-id" value="Edit" style="width: 60px; height: 30px; text-align: center; font-size: 12px" actionListener="#{func_admin_user.handEdit()}" oncomplete="UserDialog.show()" update=":form_main_admin:tblUser_Data :form_main_admin:dialogUser" process="@this :form_main_admin:tblUser_Data" disabled="#{not func_admin_user.ctrlEdit}"></p:commandButton>
                        <p:commandButton id="del-id" value="Delete" style="width: 70px; height: 30px; text-align: center; font-size: 12px" actionListener="#{func_admin_user.handDel()}" update=":form_main_admin:tblUser_Data" process="@this :form_main_admin:tblUser_Data" onclick="if (!confirm('Are you sure to delete this user ?')) return false" disabled="#{not func_admin_user.ctrlDel}"></p:commandButton>
                    </f:facet> 
                </p:dataTable>
                <p:dialog id="dialogUser" header="#{func_admin_user.statusDialog}" widgetVar="UserDialog" resizable="false" style="font-size: 15px" 
                          width="250" showEffect="clip" hideEffect="fold">  

                    <h:panelGrid id="display" columns="2" cellpadding="4">  
                        <h:outputText value="User ID:" rendered="#{not func_admin_user.add}"/>  
                        <h:inputText value="#{func_admin_user.user.USER_ID}" style="width: 110px" required="true" disabled="true" rendered="#{not func_admin_user.add}"/>  

                        <h:outputText value="User Name:" />  
                        <h:inputText value="#{func_admin_user.user.USER_NAME}" style="width: 110px" required="true"/>  

                        <h:outputText value="Password:" />  
                        <h:inputText value="#{func_admin_user.user.USER_PASSWORD}" style="width: 110px" required="true"/>  

                        <h:outputText value="Full Name:" />  
                        <h:inputText value="#{func_admin_user.user.FULL_NAME}" style="width: 110px" required="true"/>   

                        <h:outputText value="Status:" />  
                        <p:selectOneMenu value="#{func_admin_user.user.USER_STATUS}" style="width: 110px">  
                            <f:selectItem itemLabel="Disable" itemValue="0"/>  
                            <f:selectItem itemLabel="Enable" itemValue="1"/>  
                        </p:selectOneMenu>

                        <h:outputText value="Email:" />  
                        <h:inputText value="#{func_admin_user.user.USER_EMAIL}" style="width: 110px" required="true"/>   

                        <h:outputText value="Group" />  
                        <p:selectOneMenu value="#{func_admin_user.curGr.GROUP_ID}" style="width: 110px">  
                            <f:selectItems value="#{func_admin_user.listGroup}" var="list" itemLabel="#{list.GROUP_NAME}" itemValue="#{list.GROUP_ID}"></f:selectItems>  
                        </p:selectOneMenu>
                        <f:facet name="footer">
                            <p:commandButton value="OK" style="font-size: 12px; width: 50px; height: 25px" actionListener="#{func_admin_user.handOk()}" update=":form_main_admin:tblUser_Data :form_main_admin:dialogUser" process="@this :form_main_admin:dialogUser" oncomplete="#{func_admin_user.showOrDide()}"></p:commandButton>
                            <p:commandButton value="Cancel" style="font-size: 12px; width: 70px; height: 25px" oncomplete="UserDialog.hide()" update=":form_main_admin:tblUser_Data" process="@parent" actionListener="#{func_admin_user.cancel()}"></p:commandButton>
                        </f:facet>
                    </h:panelGrid>  
                </p:dialog>  
            </p:outputPanel>
        </ui:composition>
    </h:body>
</html>
